package com.hoshino.momochi.model.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hoshino.momochi.model.CreateTime;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
public class Blog extends CreateTime {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @TableField(value = "create_time")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @TableField("last_update_time")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdateTime;

    @TableField("blog_name")
    private String blogName;

    @TableField("brief")
    private String brief; // 概述

    @TableField("content")
    private String content; // 正文内容

    @TableField(exist = false)
    private Long views; //浏览量

    @TableField(exist = false)
    private Long blogLikes; // 点赞数量

    @TableField(exist = false)
    private Long blogStars; // 收藏数量

    @TableField(exist = false)
    private List<String> tags; // 标签列表

    @TableField(exist = false)
    private UserDetails userDetails; // 博客作者信息

    @TableField(exist = false)
    private Long commentNum; //评论数量

    @TableField(exist = false)
    private boolean youLike; // 用户是否点赞

    @TableField(exist = false)
    private boolean youStar; // 用户是否收藏

    @TableField(exist = false)
    private boolean youFocus; // 用户是否关注

    @TableField("isDelete")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) // 禁止 序列化
    private int isDelete;

    @TableField(exist = false)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date commentCreateTime;

    @TableField(exist = false)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date historyCreateTime;

    public Date getCreateTime() {
        return createTime;
    }

    public Blog setCreateTime(Date createTime) {
        this.createTime = createTime;
        return this;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public Blog setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
        return this;
    }

}
